package com.neusoft.databus.agent.pool.netty;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class NettyWrapper extends ChannelInboundHandlerAdapter {
    private Channel channel;

    private List<byte[]> packets = Collections.synchronizedList(new ArrayList<>());

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        final byte[] packet = (byte[]) msg;
        this.packets.add(packet);
    }

    public void clear() {
        this.packets.clear();
    }

}
